//
//  YKClientExchangeItemCell.m
//  YunKang
//
//  Created by leoking870 on 2017/10/18.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientExchangeItemCell.h"
#import "YKDashView.h"
@interface YKClientExchangeItemCell ()
@property (weak, nonatomic) IBOutlet UILabel *requestIDLabel;
@property (weak, nonatomic) IBOutlet UILabel *clientNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *requestDateLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@end

@implementation YKClientExchangeItemCell
@dynamic tableViewItem;
- (void)cellLoadSubViews {
    [super cellLoadSubViews];
    self.requestIDLabel.tf_weight = 3;
    self.clientNameLabel.tf_weight = 3;
    self.requestDateLabel.tf_weight = 2;
    self.statusLabel.tf_weight = 2;
    self.requestIDLabel.textAlignment = NSTextAlignmentLeft;
    self.requestDateLabel.textAlignment = NSTextAlignmentCenter;
    self.statusLabel.textAlignment = NSTextAlignmentCenter;
    
    [@[self.requestIDLabel, self.clientNameLabel,  self.requestDateLabel,self.statusLabel] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.top.equalTo(self.contentView.mas_top).offset(11);
    }];
    
    [@[self.requestIDLabel, self.clientNameLabel,  self.requestDateLabel,self.statusLabel] mas_alignWeightlyAlongAxis:MASAxisTypeHorizontal
                                                                                                           fixedSpace:@2
                                                                                                            leadingTo:self.contentView.mas_leading
                                                                                                            leadSpace:13
                                                                                                           trailingTo:self.contentView.mas_trailing
                                                                                                            tailSpace:13];
    
    YKDashView* dashView = [[YKDashView alloc]init];
    dashView.lineWidth = .5f;
    dashView.lineColor = [UIColor tf_colorWithHexString:@"#d4d4d4"];
    dashView.dashLineLength = 3;
    [self addSubview:dashView];
    [dashView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self);
        make.height.mas_equalTo(1);
    }];
    
}

- (void)cellWillAppear {
    [super cellWillAppear];
    if (self.tableViewItem.model) {
        
        self.requestIDLabel.text = self.tableViewItem.model.APPLY_CODE;
        self.clientNameLabel.text = self.tableViewItem.model.C_NAME;
        self.requestDateLabel.text = [[self.tableViewItem.model.APPLY_DATE componentsSeparatedByString:@" "]firstObject];
        if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"0"]) {
            self.statusLabel.text = @"未处理";
        }
        
        else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"1"]) {
            self.statusLabel.text = @"审批中";
        }
        else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"2"]) {
            self.statusLabel.text = @"已通过";
        }
        else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"3"]) {
            self.statusLabel.text = @"被驳回";
        }else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"4"]) {
            self.statusLabel.text = @"被退回";
        }
    }
}
@end
